Don't crash if D103 icon isn't found.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 24 Jul 2004 20:23:04 +0000 (20:23 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 24 Jul 2004 20:23:04 +0000 (20:23 +0000)
gpsbabel/garmin.c

index d3cd6cd3de1fef1cd6490f6c21f34b64a9aa790c..26e425f67efd2a078b39c517606ae2c7abef63e0 100644 (file)
@@ -415,6 +415,7 @@ waypoint_write(void)
        }
 
        i = 0;
+
        QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
                waypoint *wpt;
                char *ident;
@@ -455,6 +456,7 @@ waypoint_write(void)
                } else {
                        icon = mps_find_icon_number_from_desc(wpt->icon_descr, PCX);
                }
+
                /* For units that support tiny numbers of waypoints, just
                 * overwrite that and go very literal.
                 */
@@ -467,6 +469,7 @@ waypoint_write(void)
                }
                i++;
        }
+
        if ((ret = GPS_Command_Send_Waypoint(portname, way, n, waypt_write_cb)) < 0) {
                fatal(MYNAME ":communication error sending wayoints..\n");
        }
@@ -655,6 +658,10 @@ d103_icon_number_from_symbol(const char *s)
 {
        int i;
 
+       if (NULL == s) {
+               return 0;
+       }
+
        for (i = 0; i < sizeof(d103_icons) / sizeof(d103_icons[0]); i++) {
                if (0 == case_ignore_strcmp(s, d103_icons[i]))
                        return i;